﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;
using System.ComponentModel;
using System.Runtime.CompilerServices;

using KELT.Viewport;

using KELT.KELTObjects.ViewportObjectModel;

namespace KELT
{
    public class AnimationInfo 
    {
        public static string ANIMATION_ALPHA = "ANIMATION_ALPHA";
        public static string ANIMATION_SCALE = "ANIMATION_SCALE";
        public static string ANIMATION_ROTATE = "ANIMATION_ROTATE";
        public static string ANIMATION_TRANSLATE = "ANIMATION_TRANSLATE";
        public static string ANIMATION_ROTATE_BACK = "_BACK";
    }

    public abstract class IAnimation : INotifyPropertyChanged
    {
        protected string m_animationName;
        protected double m_startTime = 0.0;
        protected double m_endTime = 1.0;

        #region Get/Set
        public double startTime
        {
            get
            {
                return m_startTime;
            }

            set
            {
                m_startTime = value;

                NotifyPropertyChanged("startTime");
                NotifyPropertyChanged("duration");

                ViewPortMgr viewPortMgr;
                viewPortMgr = (ViewPortMgr)Application.Current.FindResource("ViewportMgr");
                changeAnimation(viewPortMgr.myStoryboard);
            }
        }

        public double endTime
        {
            get
            {
                return m_endTime;
            }

            set
            {

                m_endTime = value;
                
                NotifyPropertyChanged("endTime");
                NotifyPropertyChanged("duration");

                ViewPortMgr viewPortMgr;
                viewPortMgr = (ViewPortMgr)Application.Current.FindResource("ViewportMgr");
                changeAnimation(viewPortMgr.myStoryboard);
            }
        }

        public double duration
        {
            get
            {
                return m_endTime - m_startTime;
            }
        }

        public string animationName
        {
            get
            {
                return m_animationName;
            }
            set
            {
                m_animationName = value;
                NotifyPropertyChanged("animationName");
            }
        }
        #endregion

        #region XML
        // public void 
        #endregion

        public abstract void SetAnimation(Storyboard myStoryboard, ViewportObj obj);
        public abstract void changeAnimation(Storyboard myStoryboard);
        public abstract void deleteAnimation(Storyboard myStoryboard);

        public void NotifyPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
